<!DOCTYPE html>
<html>

<head>
    <title>MediaType Unit Tests</title>

    <link rel="stylesheet" href="//cdn.jsdelivr.net/qunit/1.14.0/qunit.css" />

    <script type="text/javascript" src="//cdn.jsdelivr.net/g/qunit@1.14.0,underscorejs@1.6.0"></script>

    <!-- build:js https://cdn.knightlab.com/libs/timeline3/%(cdn)s/js/timeline-min.js -->
    <script src="/dist/js/timeline.js"></script>
    <!-- endbuild -->


    <script type="text/javascript">
        // for simple tests, just add a tuple [url,mediatype.type]
        // Optionally add a third item in the tuple for a more verbose
        // description of what is being tested.
        MEDIA_TYPE_TESTS = [
            // TL.Media.YouTube
            ['https://www.youtube.com/watch?v=pi2v1m6gmD8&t=5m21s', 'youtube', 'YouTube with time stamp'],
            ['//www.youtube.com/watch?v=pi2v1m6gmD8', 'youtube', 'YouTube with no protocol'],
            ['youtu.be/pi2v1m6gmD8', 'youtube', 'YouTu.be short url'],
            ['http://vimeo.com/20839673', 'vimeo'],
            ['http://www.dailymotion.com/video/x2fo0e8_the-history-of-advertising-in-60-seconds_lifestyle', 'dailymotion'],
            ['https://vine.co/v/Og5Ai71WHdD', 'vine'],
            ['https://soundcloud.com/usher-raymond-music/usher-i-dont-mind-feat-juicy-j', 'soundcloud'],
            ['https://twitter.com/NASASpaceflight/status/562327074384654336', 'twitter'],
            ['<blockquote class="twitter-tweet" lang="en"><p>Rough vs. smooth: the Anuket and Anubis regions on <a href="https://twitter.com/hashtag/67P?src=hash">#67P</a> <a href="http://t.co/kOyAiOKlma">http://t.co/kOyAiOKlma</a> <a href="https://twitter.com/hashtag/CometWatch?src=hash">#CometWatch</a> <a href="http://t.co/YmQ8bP5WbS">pic.twitter.com/YmQ8bP5WbS</a></p>&mdash; ESA Rosetta Mission (@ESA_Rosetta) <a href="https://twitter.com/ESA_Rosetta/status/563722810397560832">February 6, 2015</a></blockquote>', 'twitterembed'],
            ['https://www.google.com/maps/@42.032147,-87.6689625,15z', 'googlemaps', 'Google Maps with lat/long'],
            ['https://www.google.com/maps/search/target/@41.8747339,-87.6481257,13z?hl=en-US', 'googlemaps', 'Google Maps with search'],
            ['https://www.google.com/maps/place/Northwestern+University/@42.056459,-87.675267,17z/data=!3m1!4b1!4m2!3m1!1s0x880fd00b703e4c39:0x2c37b567fad56106', 'googlemaps', 'Google Maps with place'],
            ['https://www.google.com/maps/dir/W+Adams+St+%26+S+Clark+St,+Chicago,+IL/Northwestern+University,+633+Clark+Street,+Evanston,+IL+60208/@41.9672743,-87.7225481,12z/data=!3m1!4b1!4m13!4m12!1m5!1m1!1s0x880e2cbc8bcec53b:0x72d2c7372d97283d!2m2!1d-87.6308023!2d41.8794067!1m5!1m1!1s0x880fd00b703e4c39:0x2c37b567fad56106!2m2!1d-87.675267!2d42.056459', 'googlemaps', 'Google Maps with directions'],
            // google plus not specifically supported
            // ['https://lh4.googleusercontent.com/-QO1O34U4z7k/Ui4OnAkgWjI/AAAAAAAAQv4/eDSXlUlwcKs/w622-h415-no/IMG_7898.JPG', 'googleplus'],
            ['http://instagram.com/p/ymwL5JAsw5/', 'instagram'],
            ['http://instagram.com/lukerague/', 'profile'],
            ['https://www.flickr.com/photos/critterseeker/16420145375', 'flickr'],
            ['https://flic.kr/p/u7SSxw', 'flickr'],
            ['https://www.documentcloud.org/documents/1377371-folketinget.html', 'documentcloud'],
            ['http://www.kidzone.ws/images-changed/sharks/head.jpg', 'image', 'JPG'],
            ['http://usatlife.files.wordpress.com/2014/06/groundhog-day-bill-murray-winter-never-going-to-end.gif', 'image', 'GIF'],
            ['http://pngimg.com/upload/banana_PNG842.png', 'image', 'PNG'],
            ['http://upload.wikimedia.org/wikipedia/commons/c/c2/Rocky_Mountains.jpeg', 'image', 'JPEG'],
            ['https://docs.google.com/document/d/1RvKYxHuwweIP8zRrnjad-0exVoZOUsSVgDYPp0J1mzY/edit?usp=sharing', 'googledocs'],
            ['http://stlab.adobe.com/wiki/images/d/d3/Test.pdf', 'pdf'],
            ['https://en.wikipedia.org/wiki/1997_International_Tennis_Championships_%E2%80%93_Doubles', 'wikipedia'],
            ['<iframe src="https://embed.spotify.com/?uri=https://play.spotify.com/artist/2iE18Oxc8YSumAU232n4rW" width="300" height="380" frameborder="0" allowtransparency="true"></iframe>', 'spotify', 'artist'],
            ['https://play.spotify.com/user/edvard_m/playlist/4xFSdiuP4gpR4wq2OghlOs', 'spotify', 'playlist'],
            ['https://play.spotify.com/track/5SdB3onMcO9ZBoKrdvCqhR', 'spotify', 'track'],
            ["<iframe src='https://cdn.knightlab.com/libs/timeline/latest/embed/index.html?source=10fFZXg4kioMz8uTVDZfawiJkgrWZxfJuziK1i1AaCrs&font=Bevan-PotanoSans&maptype=toner&lang=en&height=650' width='100%' height='650' frameborder='0'></iframe>", 'iframe'],
            ['https://storify.com/IllinoisStateU/best-campus-photos-january-2015', 'storify'],
            // website media type not currently supported
            // ['http://www.theonion.com/articles/measles-epidemic-2015-a-timeline-of-the-outbreak,37870/', 'website'],
            ['http://instagram.com/lukerague', 'profile'],
            ['<blockquote>This is a block quote.</blockquote>', 'blockquote'],
            ['http://2.bp.blogspot.com/-dxJbW0CG8Zs/TmkoMA5-cPI/AAAAAAAAAqw/fQpsz9GpFdo/s1600/voyage-dans-la-lune-1902-02-g.jpg', 'image'],
        ]
        test("Looping MediaType tests", function() {

            for (var i = 0; i < MEDIA_TYPE_TESTS.length; i++) {
                var url = MEDIA_TYPE_TESTS[i][0],
                    expected_type = MEDIA_TYPE_TESTS[i][1];

                var expectation = MEDIA_TYPE_TESTS[i][2] || "Expected " + expected_type
                var mediatype = TL.MediaType({
                    url: url
                });
                equal(mediatype.type, expected_type, "Expected " + expected_type);
            }

        });


        // these tests were in the unit-tests.html when we only had one test page
        test("original URL tests", function() {

            function mediaTypeEqual(url, expected) {
                var d = TL.MediaType({
                    'url': url
                })
                return equal(d.type, expected, expected);
            }

            mediaTypeEqual('https://www.flickr.com/photos/cleopatra69/5399251313/in/photostream', 'flickr')

            mediaTypeEqual('http://en.wikipedia.org/wiki/Project_Gutenberg', 'wikipedia')

            // documentcloud
            mediaTypeEqual('http://www.documentcloud.org/documents/346266-healthcarefullplan.js', 'documentcloud')
            mediaTypeEqual('https://www.documentcloud.org/documents/1497900-new-orleans-harbor-police-la-for-fy-2013.html', 'documentcloud')

            //Google map view
            mediaTypeEqual('https://www.google.com/maps/@42.0563195,-87.6969445,14z', 'googlemaps');

            //Google map place
            mediaTypeEqual('https://www.google.com/maps/place/Northwestern+University+Knight+Lab/@42.050703,-87.673881,17z/data=!3m1!4b1!4m2!3m1!1s0x880fd074140e35d1:0x954a22c1989c7105', 'googlemaps');


            //Google map directions
            mediaTypeEqual('https://www.google.com/maps/dir/38325+Pepperweed+Rd,+Squaw+Valley,+CA+93675/Kings+Canyon+National+Park,+California/@36.7824144,-119.2024213,10z/data=!3m1!4b1!4m13!4m12!1m5!1m1!1s0x809511dce15514c5:0x907f3cccddac00b3!2m2!1d-119.165587!2d36.679918!1m5!1m1!1s0x80bfd5ee5ff1a77b:0x826483b770430f4c!2m2!1d-118.555148!2d36.887855', 'googlemaps');

            //Google map search
            mediaTypeEqual('https://www.google.com/maps/search/coffee/@36.8128212,-119.7471762,15z/data=!3m1!4b1!4m5!2m4!3m3!1scoffee!2sCalifornia+State+University,+Fresno,+5241+North+Maple+Avenue,+Fresno,+CA+93740!3s0x80945d024e7effdb:0x8a47b32280fd2166', 'googlemaps');

            //Google map satellite tiles
            mediaTypeEqual('https://www.google.com/maps/place/38325+Pepperweed+Rd,+Squaw+Valley,+CA+93675/@36.6799575,-119.1647811,347m/data=!3m1!1e3!4m2!3m1!1s0x809511dce15514c5:0x907f3cccddac00b3', 'googlemaps');

            //Google map streetview
            mediaTypeEqual('https://www.google.com/maps/@36.67911,-119.1649653,3a,75y,285.33h,79.9t/data=!3m4!1e1!3m2!1sQbOSCYjb9m-VnE-GcqwWEA!2e0', 'googlemaps');

        });
    </script>
</head>

<body>
    <div id="qunit"></div>
</body>

</html>